<template>
  <el-row :gutter="24" class="panel-group">
    <el-col
    :xs="12"
    :sm="12"
    :lg="6"
    v-for="item in ico_list"
    class="card-panel-col">
      <div :style="{'backgroundColor': item.color}" class="card-panel" @click="handleSetLineChartData('newVisitis')">
        <div class="card-panel-icon-wrapper icon-people">
          <svg-icon :icon-class="item.ico" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            {{item.name}}
          </div>
          <count-to :decimals='2' :start-val="0" :end-val="item.number" :duration="2600" class="card-panel-num" />
        </div>
      </div>
    </el-col>

  </el-row>
</template>

<script>
  import CountTo from 'vue-count-to'
  import {indexdata} from '@/api/public.js'
  export default {
    data(){
      return {
        ico_list:[
          {
            name:'今日新增用户',
            number:0,
            ico:'xzyh',
            color:'#3B88FF',
            is_sy:false
          },
          {
            name:'今日收益',
            number:0,
            ico:'jrsy',
            color:'#FA6162',
            is_sy:true
          },
          {
            name:'今日活动在投',
            number:0,
            ico:'jrhd',
            color:'#FFC744',
            is_sy:false
          },
          {
            name:'今日投票数',
            number:0,
            ico:'jrtp',
            color:'#78DA3F',
            is_sy:false
          },
          {
            name:'平台总流水',
            number:0,
            ico:'muban',
            color:'#34c4f0',
            is_sy:true
          },
          {
            name:'本周流水',
            number:0,
            ico:'huodong',
            color:'#25b076',
            is_sy:true
          },
          {
            name:'本月流水',
            number:0,
            ico:'fzr',
            color:'#ef600c',
            is_sy:true
          },
          {
            name:'上月流水',
            number:0,
            ico:'liwu',
            color:'#ee2727',
            is_sy:true
          }
        ]
      }
    },
    components: {
      CountTo
    },
    created(){
      this.getdata()
    },
    methods: {
      handleSetLineChartData(type) {
        this.$emit('handleSetLineChartData', type)
      },
      getdata(){

        var than = this
        var userinfo = JSON.parse(localStorage.getItem("userInfo"))
        indexdata({

        }).then(res => {

          this.ico_list = [
          {
            name:'今日新增用户',
            number:res.data.data.xzyh,
            ico:'xzyh',
            color:'#3B88FF'
          },
          {
            name:userinfo.is_show_sy==0?'今日收益':'暂未开放',
            number:userinfo.is_show_sy==0?res.data.data.jrsy:0,
            ico:'jrsy',
            color:'#FA6162'
          },
          {
            name:'今日活动在投',
            number:res.data.data.jrhd,
            ico:'jrhd',
            color:'#FFC744'
          },
          {
            name:'今日投票数',
            number:res.data.data.jrtps,
            ico:'jrtp',
            color:'#78DA3F'
          },
          {
            name:userinfo.is_show_sy==0?'平台总流水':'暂未开放',
            number:userinfo.is_show_sy==0?res.data.data.muban:0,
            ico:'muban',
            color:'#34c4f0'
          },
          {
            name:userinfo.is_show_sy==0?'本周流水':'暂未开放',
            number:userinfo.is_show_sy==0?res.data.data.xthds:0,
            ico:'huodong',
            color:'#25b076'
          },
          {
            name:userinfo.is_show_sy==0?'本月流水':'暂未开放',
            number:userinfo.is_show_sy==0?res.data.data.xtfzr:0,
            ico:'fzr',
            color:'#ef600c'
          },
          {
            name:userinfo.is_show_sy==0?'上月流水':'暂未开放',
            number:userinfo.is_show_sy==0?res.data.data.xtlws:0,
            ico:'liwu',
            color:'#ee2727'
          }
        ]

        }).catch((res) => {

        })
      }
    }
  }
</script>

<style lang="scss" scoped>

  .panel-group {
    margin-top: 18px;

    .card-panel-col {
      margin-bottom: 32px;

    }

    .card-panel {
      border-radius: 5px;
      height: 108px;
      cursor: pointer;
      font-size: 12px;
      position: relative;
      overflow: hidden;
      color: #fff !important;
      background: #fff;
      box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
      //box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
      border-color: rgba(0, 0, 0, .05);



      .icon-people {
        color: #fff;
      }

      .icon-message {
        color: #fff;
      }

      .icon-money {
        color: #fff;
      }

      .icon-shopping {
        color: #fff
      }

      .card-panel-icon-wrapper {
        float: left;
        margin: 14px 0 0 14px;
        padding: 16px;
        transition: all 0.38s ease-out;
        border-radius: 6px;
      }

      .card-panel-icon {
        float: left;
        font-size: 48px;
      }

      .card-panel-description {
        float: right;
        font-weight: bold;
        margin: 26px;
        margin-left: 0px;

        .card-panel-text {
          line-height: 18px;
          color: fff;
          font-size: 16px;
          margin-bottom: 12px;
        }

        .card-panel-num {
          font-size: 26px;
          font-weight: bolder;
        }
      }
    }
  }

  @media (max-width:550px) {
    .card-panel-description {
      display: none;
    }

    .card-panel-icon-wrapper {
      float: none !important;
      width: 100%;
      height: 100%;
      margin: 0 !important;

      .svg-icon {
        display: block;
        margin: 14px auto !important;
        float: none !important;
      }
    }
  }
</style>
